<template>
  <div>
    <van-nav-bar
      :title="comment.reply_count?comment.reply_count+'评论':'暂无评论'"
    >
      <template #left>
        <van-icon name="cross" @click="$emit('close')" />
      </template>
    </van-nav-bar>
    <div class="scrollcontent">
    <comment-item :obj="comment"></comment-item>
    <van-cell title="全部回复"  />

    <comment-list :list="list" type="c" :source="comment.com_id+''"></comment-list>

    <div class="post-warp">
      <van-button round @click="show=true">评论</van-button>
    </div>
   </div>
   <!-- 评论的评论的弹层 -->
   <van-popup v-model="show" position="bottom"  >
      <comment-post @closepopup='closepop' :target="comment.com_id+''" :art_id="$route.params.art_id"></comment-post>
   </van-popup>
  </div>
</template>

<script>
import CommentItem from './CommentItem.vue'
import CommentList from './CommentList.vue'
import CommentPost from './CommentPost.vue'
export default {
  components: { CommentItem, CommentList, CommentPost },
  data () {
    return {
      list: [],
      show: false
    }
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },

  created () {

  },

  methods: {
    closepop (val) {
      this.list.unshift(val)
      this.show = false
      this.comment.reply_count++
    }
  }
}
</script>

<style scoped lang='less'>
.scrollcontent {
  position: absolute;
  top: 92px;
  bottom: 100px;
  width: 100%;
  overflow-y: scroll;
}
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hotpink;
  .van-button {
    width: 640px;
    height: 80px;
  }
}

</style>
